//
//  YTKChainRequest+AnimatingAccessory.m
//  HaloBear
//
//  Created by monkey on 16/12/14.
//  Copyright © 2016年 刘～丹. All rights reserved.
//

#import "YTKChainRequest+AnimatingAccessory.h"
#import "YTKAnimatingRequestAccessory.h"

@implementation YTKChainRequest (AnimatingAccessory)

- (YTKAnimatingRequestAccessory *)animatingRequestAccessory {
    for (id accessory in self.requestAccessories) {
        if ([accessory isKindOfClass:[YTKAnimatingRequestAccessory class]]){
            return accessory;
        }
    }
    return nil;
}

-(UIView *)datasourceView
{
    return self.animatingRequestAccessory.datasourceView;
}


-(void)setDatasourceView:(UIView *)datasourceView
{
    if (!self.animatingRequestAccessory) {
        [self addAccessory:[YTKAnimatingRequestAccessory accessoryWithAnimatingView:nil animatingText:nil datasourceView:datasourceView]];
    } else {
        self.animatingRequestAccessory.datasourceView = datasourceView;
    }
}

- (UIView *)animatingView {
    return self.animatingRequestAccessory.animatingView;
}

- (void)setAnimatingView:(UIView *)animatingView {
    if (!self.animatingRequestAccessory) {
        [self addAccessory:[YTKAnimatingRequestAccessory accessoryWithAnimatingView:animatingView animatingText:nil]];
    } else {
        self.animatingRequestAccessory.animatingView = animatingView;
    }
}

- (NSString *)animatingText {
    return self.animatingRequestAccessory.animatingText;
}

- (void)setAnimatingText:(NSString *)animatingText {
    if (!self.animatingRequestAccessory) {
        [self addAccessory:[YTKAnimatingRequestAccessory accessoryWithAnimatingView:nil animatingText:animatingText]];
    } else {
        self.animatingRequestAccessory.animatingText = animatingText;
    }
}

@end
